<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
	</head>
	<body>
	</body>
	<script type="text/javascript">
//		封装一个ajax方法
		const getJson=(url)=>{
			return new Promise((resolved,rejected)=>{
				const xhr = new XMLHttpRequest();
				xhr.open("GET",url);
				xhr.onreadystatechange = handler;
				xhr.responseType ="json";
				xhr.setRequestHeader("Accept","application/json");
				xhr.send()
				function handler(){
//					console.log(this)
					if(this.readyState==4){
						if(this.status==200){
							resolved(this.response)
						}else{
//							rejected(new Error(this.statusText))
							rejected(new Error("数据为空"))
						}
					}
				}
			})
		}

		getJson("http://120.48.109.174:8081/area/hot").then((res)=>{
			console.log(res)
		},(error)=>{
			console.log(error)
		});
		
		
		
	</script>
</html>
